<script type='text/javascript' src='${base}/dwr/engine.js'></script>
<script type='text/javascript' src='${base}/dwr/util.js'></script>
<script type='text/javascript' src='${base}/dwr/interface/backUserService.js'></script>

<script type="text/javascript">
	j(function(){
		<#if roleStrs?exists && roleStrs?size gt 0>
			<#list roleStrs as roleStr>
				j("#br_${roleStr}").attr("checked","checked");
			</#list>
		</#if>
	})


	function closerparent(){
	    parent.floatboxclose(false);
	}
	
	function checkForm(){
		if(j("#checkRoles input[type='checkbox']:checked").size() == 0){
			alert("请至少选择一个角色关联用户");
			return;
		}
		var roleStr="";
		j("#checkRoles input[type='checkbox']:checked").each(function(i,role){
			roleStr+=role.value+",";
		})
		roleStr=roleStr.substring(0,roleStr.length-1);
		var callBack=function(o){
			parent.addNewUserSuccess(o,"关联");
			closerparent();
		}
		backUserService.ralationBackUserAndRole("${backUser.id?if_exists}",roleStr,callBack)
	}


</script>
<div class="container" id="cpcontainer">
<div class="close"></div>
<div class="itemtitle"><h3>设置用户角色</h3></div>
<form>
<table border="0" class="tb tb2" >
	<tr>
		<td class=td21>用户昵称：</td>
		<td>${backUser.nickname?if_exists}</td>
	</tr>

	<tr>
		<td colspan="2" id="checkRoles">
			<#if backRoles?exists && backRoles?size gt 0>
				<#list backRoles as backRole>
					<input id="br_${backRole.id?if_exists}" type="checkbox" value="${backRole.id?if_exists}">${backRole.name?if_exists}&nbsp;
				</#list>
			</#if>
		</td>
	</tr>

	<tr>
		<td colspan="3">
			<INPUT type="button"  value="     设置     " onclick ="checkForm()"/>&nbsp;&nbsp;
			<INPUT type="button"  value="     取消     " onclick ="closerparent()"/>
		</td>
	</tr>
</table>
</form>

</div>